package com.library.framework.security.provider.token;

import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.core.GrantedAuthority;

import java.util.Collection;

/**
 * @Package: com.educationalsystem.framework.security.provider
 * @ClassName: WechatCodeLoginAuthenticationToken
 * @Author: Yin
 * @Date: 11:40
 * @Description: 此文件描述信息
 */
public class WechatAccountLoginAuthenticationToken extends AbstractAuthenticationToken {

    private static final long serialVersionUID = 1L;

    /** 账号为学号 */
    private String username;
    /** 身份证卡后四位 */
    private String password;
    /** 前端给的登陆code-暂不使用 */
    @Deprecated
    private String code;
    /** 登录类型 */
    private String type;
    private Object principal;
    private Object credentials;

    public WechatAccountLoginAuthenticationToken(String username, String password, String code) {
        super(null);
        this.username = username;
        this.password = password;
        this.code = code;
        this.setAuthenticated(false);
    }

    public WechatAccountLoginAuthenticationToken(Collection<? extends GrantedAuthority> authorities) {
        super(authorities);
    }

    public WechatAccountLoginAuthenticationToken(Object principal, Object credentials, Collection<? extends GrantedAuthority> authorities) {
        super(authorities);
        this.principal = principal;
        this.credentials = credentials;
        super.setAuthenticated(true);
    }

    @Override
    public Object getCredentials() {
        return this.credentials;
    }

    @Override
    public Object getPrincipal() {
        return this.principal;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }
}
